package cn.xdf.demo01;

import cn.xdf.entity.Goods;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.junit.Test;

public class Demo01 {

    private HttpSolrServer solrServer=new HttpSolrServer("http://localhost:9090/solr/Goods");


    //增
    @Test
    public void test01() throws Exception{

        Goods goods=new Goods();
        goods.setId("888");
        goods.setTitle("华为五折叠手机好用");
        goods.setName("怎么用都好用");
        goods.setPrice(99999990.0D);
        goods.setPic("http:///");

        solrServer.addBean(goods);
        solrServer.commit();
    }

    //删除
    @Test
    public void test02() throws Exception{

        solrServer.deleteById("888");
        solrServer.commit();
    }

    @Test
    public void test03() throws Exception{

        Goods goods=new Goods();
        goods.setId("888");
        goods.setTitle("华为八折叠手机好用");
        goods.setName("不好用");
        goods.setPrice(9.0D);
        goods.setPic("http:///");
        solrServer.addBean(goods);

        solrServer.commit();
    }
}
